//
//  GoOutAcePackCollectionView.m
//  ArtOfLiving
//
//  Created by 刘虎 on 16/5/2.
//  Copyright © 2016年 刘虎. All rights reserved.
//

#import "GoOutAcePackCollectionView.h"
#import "GoOutAcePackCollectionViewCell.h"
#import "GoOutAcePackTopicModel.h"
#import "GoOutAcePackDetailViewController.h"

@interface GoOutAcePackCollectionView ()<UICollectionViewDelegate, UICollectionViewDataSource>


@end

@implementation GoOutAcePackCollectionView

- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(nonnull UICollectionViewLayout *)layout {
    
    self = [super initWithFrame:frame collectionViewLayout:layout];
    if (self) {
        
        self.delegate = self;
        self.dataSource = self;
        [self registerNib:[UINib nibWithNibName:@"GoOutAcePackCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"GoOutAcePackCELL"];
    }
    return self;
}

#pragma mark - ----collectionView的代理方法-------

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    
    return self.dataSourceMArr.count;
}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    GoOutAcePackCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"GoOutAcePackCELL" forIndexPath:indexPath];
    cell.model = self.dataSourceMArr[indexPath.row];
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    
    GoOutAcePackTopicModel *model = [self.dataSourceMArr objectAtIndex:indexPath.row];
    UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    GoOutAcePackDetailViewController *goOutAcePackDetailVC = [mainStoryboard instantiateViewControllerWithIdentifier:@"GoOutAcePackDetailViewController"];
    goOutAcePackDetailVC.guideID = model.guide_id;
    goOutAcePackDetailVC.navCTitle = model.guide_enname;
    [self.navC pushViewController:goOutAcePackDetailVC animated:YES];
}


#pragma mark - ----属性懒加载-----
- (NSMutableArray *)dataSourceMArr {
    
    if (!_dataSourceMArr) {
        
        _dataSourceMArr = [[NSMutableArray alloc] init];
    }
    return _dataSourceMArr;
}


@end
